let utils = {
  changImgURL(accid) {
    switch (accid) {
      case "1":
        break;
      case "2":
        break;
      case "3":
        break;
      default:
        break;
    }
  },
  timeFormate() {
    let timeStamp = new Date();
    let year = new Date().getFullYear();
    let month = new Date(timeStamp).getMonth() + 1 < 10 ? "0" + (new Date(timeStamp).getMonth() + 1) : new Date(timeStamp).getMonth() + 1;
    let date = new Date(timeStamp).getDate() < 10 ? "0" + new Date(timeStamp).getDate() : new Date(timeStamp).getDate();
    let hh = new Date(timeStamp).getHours() < 10 ? "0" + new Date(timeStamp).getHours() : new Date(timeStamp).getHours();
    let mm = new Date(timeStamp).getMinutes() < 10 ? "0" + new Date(timeStamp).getMinutes() : new Date(timeStamp).getMinutes();
    let ss = new Date(timeStamp).getSeconds() < 10 ? "0" + new Date(timeStamp).getSeconds() : new Date(timeStamp).getSeconds();
    return year + "-" + month + "-" + date + " " + hh + ":" + mm + ":" + ss;
  },
  getTime(){
    let timeStamp = new Date().getTime();
    console.log(timeStamp)
    return timeStamp
  },
  fromatPushTime() {
    let date = new Date();
    let year = date.getFullYear(),
      month = date.getMonth() + 1,
      day = date.getDate();
    let newTime = year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
    return newTime;
  },
  monthDay() {
    var nowdays = new Date();
    var year = nowdays.getFullYear();
    var month = nowdays.getMonth();
    if (month == 0) {
      month = 12;
      year = year - 1;
    }
    if (month < 10) {
      month = "0" + month;
    }
    var firstDay = year + "-" + month + "-" + "01"; //上个月的第一天
    var myDate = new Date(year, month, 0);
    var lastDay = year + "-" + month + "-" + myDate.getDate(); //上个月的最后一天
    var obj = {
      firstDay,
      lastDay
    }
    return obj
  },
  formatDate(date, fmt) {
    if (/(y+)/.test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
    }
    let o = {
      'M+': date.getMonth() + 1,
      'd+': date.getDate(),
      'h+': date.getHours(),
      'm+': date.getMinutes(),
      's+': date.getSeconds()
    };
    for (let k in o) {
      if (new RegExp(`(${k})`).test(fmt)) {
        let str = o[k] + '';
        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str));
      }
    }
    return fmt;
  }
}

export default utils
